package avicit.bdp.dlm.dto;

import avicit.bdp.common.base.BaseDTO;
import avicit.bdp.common.service.dto.DataSourceDTO;
import avicit.platform6.core.annotation.log.FieldRemark;
import avicit.platform6.core.annotation.log.Id;
import avicit.platform6.core.annotation.log.LogField;
import avicit.platform6.core.properties.PlatformConstant;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.StringUtils;

import javax.persistence.Column;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * bdp_dlm_datasource实体类
 *
 * @author mayanj
 * @date 2020/12/3 9:10
 */
@ApiModel(value = "DlmDataSourceDTO", description = "bdp_dlm_datasource")
@Table(name = "bdp_dlm_datasource")
public class DlmDataSourceDTO extends BaseDTO {


    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    @Id
    @LogField
    @ApiModelProperty(value = "id", name = "id")
    @FieldRemark(column = "id", field = "id", name = "主键")
    @javax.persistence.Id
    @Column(name = "id")
    private String id;

    /**
     * 分类ID
     */
    @LogField
    @ApiModelProperty(value = "分类ID", name = "typeId")
    @FieldRemark(column = "type_id", field = "typeId", name = "分类ID")
    @Column(name = "type_id")
    private String typeId;

    /**
     * 数据源ID
     */
    @LogField
    @ApiModelProperty(value = "数据源ID", name = "dataSourceId")
    @FieldRemark(column = "data_source_id", field = "dataSourceId", name = "数据源ID")
    @Column(name = "data_source_id")
    private String dataSourceId;

    /**
     * 数据源结构
     * 结构：0-结构化  1-非结构化 2-半结构化
     */
    @LogField
    @ApiModelProperty(value = "数据源结构", name = "dataSourceStructure")
    @FieldRemark(column = "structure", field = "dataSourceStructure", name = "数据源结构")
    @Column(name = "data_source_structure")
    private Integer dataSourceStructure;

    /**
     * 节点信息
     */
    @LogField
    @ApiModelProperty(value = "节点信息", name = "nodeInfo")
    @FieldRemark(column = "node_info", field = "nodeInfo", name = "节点信息")
    @Column(name = "node_info")
    private String nodeInfo;

    /**
     * 数据库版本
     */
    @LogField
    @ApiModelProperty(value = "数据库版本", name = "dataSourceVersion")
    @FieldRemark(column = "data_source_version", field = "dataSourceVersion", name = "数据库版本")
    @Column(name = "data_source_version")
    private String dataSourceVersion;

    /**
     * 总容量
     */
    @LogField
    @ApiModelProperty(value = "总容量", name = "availableAmount")
    @FieldRemark(column = "available_amount", field = "availableAmount", name = "总容量")
    @Column(name = "available_amount")
    private Long availableAmount;

    @Transient
    private DataSourceDTO dataSourceDTO;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getTypeId() {
        return typeId;
    }

    public void setTypeId(String typeId) {
        this.typeId = typeId;
    }

    public String getDataSourceId() {
        return dataSourceId;
    }

    public void setDataSourceId(String dataSourceId) {
        this.dataSourceId = dataSourceId;
    }

    public Integer getDataSourceStructure() {
        return dataSourceStructure;
    }

    public void setDataSourceStructure(Integer dataSourceStructure) {
        this.dataSourceStructure = dataSourceStructure;
    }

    public String getNodeInfo() {
        return nodeInfo;
    }

    public void setNodeInfo(String nodeInfo) {
        this.nodeInfo = nodeInfo;
    }

    public String getDataSourceVersion() {
        return dataSourceVersion;
    }

    public void setDataSourceVersion(String dataSourceVersion) {
        this.dataSourceVersion = dataSourceVersion;
    }

    public DataSourceDTO getDataSourceDTO() {
        return dataSourceDTO;
    }

    public void setDataSourceDTO(DataSourceDTO dataSourceDTO) {
        this.dataSourceDTO = dataSourceDTO;
    }

    public Long getAvailableAmount() {
        return availableAmount;
    }

    public void setAvailableAmount(Long availableAmount) {
        this.availableAmount = availableAmount;
    }

    @Override
    public String getLogFormName() {
        if (StringUtils.isEmpty(super.logFormName)) {
            return "数据湖统计模块";
        } else {
            return super.logFormName;
        }
    }

    @Override
    public String getLogTitle() {
        if (StringUtils.isEmpty(super.logTitle)) {
            return "数据湖统计";
        } else {
            return super.logTitle;
        }
    }

    @Override
    public PlatformConstant.LogType getLogType() {
        if (super.logType == null) {
            return PlatformConstant.LogType.module_operate;
        } else {
            return super.logType;
        }
    }

    @Override
    public String toString() {
        return "DlmDataSourceDTO{" +
                "id='" + id + '\'' +
                ", typeId='" + typeId + '\'' +
                ", dataSourceId='" + dataSourceId + '\'' +
                ", dataSourceStructure=" + dataSourceStructure +
                ", nodeInfo='" + nodeInfo + '\'' +
                ", dataSourceVersion='" + dataSourceVersion + '\'' +
                ", availableAmount='" + availableAmount + '\'' +
                ", dataSourceDTO=" + dataSourceDTO +
                '}';
    }
}
